<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2024 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
use Illuminate\Support\Facades\Route;
use Illuminate\Http\Request;

Route::get('/', function (Request $request) {
	$config = cache('config', []);
	if (isset($config['site_close']) && $config['site_close'] == 1){
		return view('close');
	}
	if (Route::has('home')){
		return redirect()->route('home', $request->all());
	}else{
		if (file_exists(resource_path('web/dist/index.html'))){
			if (is_dir(resource_path('web/dist/assets')) && !is_dir(public_path('assets'))){
				symlink(resource_path('web/dist/assets'), public_path('assets'));
			}
			return file_get_contents(resource_path('web/dist/index.html'));
		}else{
			return view('welcome');
		}
	}
})->name('welcome');

Route::get('/admin', function (Request $request) {
	if (file_exists(resource_path('admin/dist/index.html'))){
		if (is_dir(resource_path('admin/dist/static')) && !is_dir(public_path('static'))){
			symlink(resource_path('admin/dist/static'), public_path('static'));
			symlink(resource_path('admin/dist/admin.js'), public_path('admin.js'));
		}
		return file_get_contents(resource_path('admin/dist/index.html'));
	}else {
		return view('welcome');
	}
})->name('admin');
